@echo off
chcp 936 >nul
cls

REM DayZ Server Manager - Simple Startup Script

ECHO ==========================================================
ECHO                DayZ SERVER MANAGER
ECHO ==========================================================

ECHO Step 1: Checking Node.js installation...
where node >nul 2>nul
if %errorlevel% neq 0 (
    ECHO.    ERROR: Node.js not found!
    ECHO.    Please install Node.js LTS version from https://nodejs.org/
    ECHO.    Make sure to check "Add to PATH" during installation
    ECHO.
    PAUSE
    EXIT
)

ECHO.    SUCCESS: Node.js is installed

ECHO. Step 2: Starting backend server...
ECHO.    Starting backend on port 5000...
ECHO.    Please wait, this may take a moment...

REM Start backend in a new window
start "DayZ Backend Server" cmd /c "chcp 936 >nul && cd %~dp0backend && npm install && node server.js"

ECHO.
ECHO ==========================================================
ECHO Backend server starting on http://localhost:5000
ECHO Please wait for backend to initialize...
ECHO ==========================================================

ECHO.
ECHO Step 3: Starting frontend development server...
ECHO.    Starting frontend on port 3000...
ECHO.

REM Wait for backend to initialize
ECHO Waiting for backend to start...
ping -n 5 127.0.0.1 >nul

REM Start frontend
cd %~dp0frontend
call npm install
call npm run dev

PAUSE